package com.citycloud.ccuap.tc.sync.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

import java.util.List;

@Data
public class DepartmentTreeDto implements Comparable<DepartmentTreeDto> {

    private Long deptId;

    private Long pid;

    @JsonIgnore
    private Boolean isParent;

    @JsonIgnore
    private String deptName;

    @JsonIgnore
    private String fullPath;

    @JsonIgnore
    private String fullIdPath;

    /** 0未处理，1未选择 2半选，3全选 */
    @JsonIgnore
    private int selected;

    @JsonIgnore
    private int granted;

    @JsonIgnore
    private List<DepartmentTreeDto> subDept;

    public boolean isChecked() {
        if (selected == 3) {
            return true;
        }
        return false;
    }

    public boolean isHalfCheck() {
        if (selected == 2) {
            return true;
        }
        return false;
    }

    public String getName() {
        return deptName;
    }

    public List<DepartmentTreeDto> getChildren() {
        return subDept;
    }

    public Boolean getIsParent() {
        if (isParent == null) {
            return subDept != null;
        } else {
            return isParent;
        }
    }

    @Override
    public int compareTo(DepartmentTreeDto o) {
        return this.fullPath.compareTo(o.getFullPath());
    }
}
